package live.sidian.database.synchronizer.sync.structure;

import live.sidian.database.synchronizer.infrastructure.sql.SqlHelper;
import live.sidian.database.synchronizer.sync.structure.MetaDataComparator.Diff;
import lombok.extern.slf4j.Slf4j;

/**
 * 结果差异补丁执行器
 *
 * @author sidian
 * @date 2021/4/5 20:37
 */
@Slf4j
public class DiffExecutor {
    SqlHelper sqlHelper;

    public DiffExecutor(SqlHelper sqlHelper) {
        this.sqlHelper = sqlHelper;
    }

    public void execute(Diff diff) {
        for (MetaDataComparator.DiffChange diffChange : diff.changes) {
            sqlHelper.execute(diffChange.val);
        }
    }
}
